
export class SysContant {

    // 游戏总时长
    private _gameTime = 0
    // 最佳时间
    private bestGameTime = 180

    // 游戏得分
    private _gameScore = 0

    // 英雄生命
    private _heroLife = 3

    // 默认生命
    public readonly defHeroLife = 3

    // 子弹类型
    static bulletIndex = 0

    private static _inst: SysContant;

    public static get inst(): SysContant {
        if (this._inst == null) {
            this._inst = new SysContant();
        }
        return this._inst;
    }

    private constructor() {}

    public get gameTime() {
        return this._gameTime
    }
    public set gameTime(time: number) {
        this._gameTime += time
    }
    public setGameTime(time: number) {
        this._gameTime = time
    }

    
    public get gameScore() : number {
        return this._gameScore
    }
    public set gameScore(socore : number) {
        this._gameScore = socore;
    }
    public addScore(score: number) {
        this._gameScore += score
    }


    
    public get heroLife() : number {
        return this._heroLife
    }
    public set heroLife(v : number) {
        this._heroLife = v;
    }
    public addHeroLife(amount: number) {
        this._heroLife += amount
    }
    public reduceHeroLife(amount: number) {
        this._heroLife -= amount
    }
    


    /**
     * 达到游戏巅峰比, 游戏时间达到 bestGameTime, 则返回1
     */
    public bestRate() {
        if(this._gameTime >= this.bestGameTime) {
            return 1
        }

        return this._gameTime / this.bestGameTime
    }


}